let crypto = require('crypto'); // 引入加密模块

// md5加密
exports.md5 = function (password) {
    let md5 = crypto.createHash('md5');
    md5.update(password);
    return md5.digest('hex');
}

// 将字符串转为base64编码
exports.toBase64 = function (password) {
    return new Buffer(password).toString('base64');
}

// 将base64编码的字符串转为字符串
exports.fromBase64 = function (password) {
    return new Buffer(password, 'base64').toString();
}